// Fim das fun��es que manipulam valores monet�rios


function mascaraPrincipal(o, f) {
    v_obj = o;
    v_fun = f;
    setTimeout("execmascara()", 1);
}

function execmascara() {
    v_obj.value = v_fun(v_obj.value);
}

function validaEntradaSomenteNumero(v) {
    return v.replace(/\D/g, "");
}

function mascaraNumero(campo) {
    var v = campo.value;
    return v.replace(/\D/g, "");
}


function mascaraData(v) {
    v = v.replace(/\D/g, "");                 //Remove tudo o que n�o � d�gito
    v = v.replace(/(\d{2})(\d)/, "$1/$2");    //Coloca uma barra entre o segundo e terceiro d�gitos
    v = v.replace(/(\d{2})(\d)/, "$1/$2");    //Coloca uma barra entre o quarto e o quinto d�gitos
    return v;
}

function mascaraHora(v) {
    v = v.replace(/\D/g, "");                 //Remove tudo o que n�o � d�gito
    v = v.replace(/(\d{2})(\d)/, "$1:$2");    //Coloca : entre o primeiro e segundo d�gitos
    return v;
}


/**
 * Aplica mai?scula
 */
function maiusculas(v) {
    return v.toUpperCase();
}


/*Fun��o que padroniza telefone 4184-1241*/
function telefone_simples(v) {
    v = v.replace(/\D/g, "")                 //Remove tudo o que não é digito
    v = v.replace(/(\d{4})$/, "-$1");   //Coloca hífen entre o quarto e o quinto dígitos 
    return v;
}

/*Fun��o que padroniza telefone (11) 4184-1241*/
function telefone(v) {
    v = v.replace(/\D/g, "");
    v = v.replace(/^(\d\d)(\d)/g, "($1) $2");
    v = v.replace(/(\d{4})(\d)/, "$1-$2");
    return v;
}


/*Fun��o que padroniza CPF*/
function cpf(v) {
    v = v.replace(/\D/g, "");
    v = v.replace(/(\d{3})(\d)/, "$1.$2");
    v = v.replace(/(\d{3})(\d)/, "$1.$2");

    v = v.replace(/(\d{3})(\d{1,2})$/, "$1-$2");
    return v;
}

/*Fun��o que padroniza CEP*/
function cep(v) {
    v = v.replace(/\D/g, "");
    v = v.replace(/^(\d{2})(\d)/, "$1.$2");
    v = v.replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2-$3");
    return v;
}

/*Fun��o que padroniza CNPJ*/
function cnpj(v) {
    v = v.replace(/\D/g, "");
    v = v.replace(/^(\d{2})(\d)/, "$1.$2");
    v = v.replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2.$3");
    v = v.replace(/\.(\d{3})(\d)/, ".$1/$2");
    v = v.replace(/(\d{4})(\d)/, "$1-$2");
    return v;
}

function mascaraOS(v) {
    v = v.replace(/\D/g, "");
    v = v.replace(/^(\d{4})(\d)/, "$1.$2");
    v = v.replace(/^(\d{4})\.(\d{5})(\d{4})/, "$1.$2-$3");
    return v;
}